<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三角函数绘制奔驰标志</title>
    <style>
        canvas{
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="600" height="600"></canvas>
    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');

        // 将坐标原点移动至画布中心
        ctx.translate(300,300);

        // 绘制圆
        const r = 100;
        ctx.arc(0,0,r, 0, 2*Math.PI, false);

        // 绘制直线
        drawLine(270);
        drawLine(30);
        drawLine(150);

        ctx.lineWidth = 3;
        ctx.stroke();

        function drawLine(deg){
            ctx.moveTo(0,0);
            let round = Math.PI/180 * deg;
            let x = r * Math.cos(round);
            let y = r * Math.sin(round);
            ctx.lineTo(x,y);
        }
    </script>
</body>
</html>